package com.wy.test.demo;

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class Generic<T, PK extends Serializable> {

	private Class<T> entityClass;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Generic(T t){ 
		this.entityClass = (Class<T>) t.getClass();
		Class c = getClass();
		Type type = c.getGenericSuperclass();
		if(type instanceof ParameterizedType){
			Type[] parameterizedType = ((ParameterizedType)type).getActualTypeArguments();
			this.entityClass = (Class<T>)parameterizedType[0];
		}
	}
	
	public Class<T> getActuralObj(){
		System.out.println("entityName --->"+ entityClass.getName());
		return entityClass;
	}

}
